package com.security.system.controller;

import cn.hutool.captcha.LineCaptcha;
import com.security.Utils.CaptchaUtils;
import com.security.system.dao.SysUserDao;
import com.security.system.entity.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@Controller
@RequestMapping("login")
public class LoginController {

    @GetMapping("")
    public String getLoginHtml(){
        return "login/login";
    }


    @GetMapping("captcha")
    public void getimg(HttpSession session, HttpServletRequest req , HttpServletResponse res) throws IOException {
        LineCaptcha lineCaptcha = CaptchaUtils.PC_Captcha();
        session.setAttribute(CaptchaUtils.CAPTCHA_SESSION_KEY,lineCaptcha.getCode());
        lineCaptcha.write(res.getOutputStream());
    }


}
